<template>
  <!-- 商店详情组件 -->
  <div>
    <div class="top-content">
      <div class="center">
        <img width="64" height="64" :src="seller.avatar" alt>
        <div class="top-tet">
          <div class="titles">
            <span class="pin_pai"></span>
            <span class="tit-biao">{{seller.name}}</span>
          </div>
          <p class="fn">{{seller.description}}/{{seller.deliveryTime}}分钟到达</p>
          <p v-if="seller.supports" class="mj">
            <span class="jian" :class="classMap[seller.supports[0].type]"></span>
            {{seller.supports[0].description}}
          </p>
        </div>
        <div class="index_length" v-if="seller.supports" @click="showDetail">
          <span>{{seller.supports.length}}个 ></span>
        </div>
      </div>
      <div class="gonggao" @click="showDetail">
        <span class="gonggao_title"></span>
        <span class="gonggao_text">{{seller.bulletin}}</span>
        <span class="gonggao_jt">></span>
      </div>
      <div class="background">
        <img :src="seller.avatar" alt width="100%" height="100%">
      </div>
      <transition name="fade">
        <div class="detail" v-show="detailShow">
          <div class="detail-wrapper clearfix">
            <div class="detail-main">
              <h1>{{seller.name}}</h1>
              <star :size="48" :score="seller.score"></star>
              <div class="title">
                <div class="line"></div>
                <div class="text">优惠信息</div>
                <div class="line"></div>
              </div>
              <ul class="supports" v-if="seller.supports">
                <li class="supports-item" v-for="(item,index) in seller.supports" :key="index">
                  <span class="jian" :class="classMap[seller.supports[index].type]"></span>
                  <span class="text">{{item.description}}</span>
                </li>
              </ul>
              <div class="title">
                <div class="line"></div>
                <div class="text">商家公告</div>
                <div class="line"></div>
              </div>
              <div class="conent">
                <p>{{seller.bulletin}}</p>
              </div>
            </div>
          </div>
          <div class="detail-close" @click="detailhiden">x</div>
        </div>
      </transition>
    </div>
    <tab :seller="seller"></tab>
  </div>
</template>

<script>
import tab from "./tab";
import star from "../components/star/star";

export default {
  components: {
    tab,
    star
  },
  data() {
    return {
      seller: {},
      detailShow: false
    };
  },
  methods: {
    showDetail() {
      this.detailShow = true;
    },
    detailhiden() {
      this.detailShow = false;
    }
  },
  created() {
    this.axios.get("http://localhost:3000/api/seller").then(res => {
      this.seller = res.data.seller;
        console.log(this.seller);
    }),
      (this.classMap = ["jian", "jian1", "jian2", "jian3", "jian4"]);
  }
};
</script>

<style lang = "scss">
.top-content {
  color: #fff;
  position: relative;
  background: rgba(7, 17, 27, 0.5);
  overflow: hidden;
  .center {
    padding: 24px 12px 18px 24px;
    font-size: 0;
    display: flex;
    align-items: center;
    position: relative;
    img {
      display: inline-block;
    }
    .top-tet {
      display: inline-block;
      margin-left: 16px;

      .titles {
        display: flex;
        align-items: center;
        margin: 2px 0 8px 0;
      }
      .pin_pai {
        display: inline-block;
        width: 30px;
        height: 18px;
        background: url("./img/brand@2x.png") no-repeat 0 0 / cover;
      }
      .tit-biao {
        font-weight: bold;
        font-size: 16px;
        margin-left: 6px;
        line-height: 18px;
      }
      .fn {
        font-weight: 200px;
        line-height: 12px;
        font-size: 12px;
        margin-bottom: 10px;
      }
      .mj {
        font-size: 10px;
        font-weight: 200px;
        line-height: 12px;
        display: flex;
        align-items: center;
      }
    }
    .index_length {
      position: absolute;
      right: 12px;
      bottom: 14px;
      padding: 0 8px;
      height: 24px;
      line-height: 24px;
      border-radius: 14px;
      background: rgba(0, 0, 0, 0.2);
      text-align: center;
      span {
        font-size: 10px;
      }
    }
  }
  .gonggao {
    height: 28px;
    line-height: 28px;
    padding: 0 22px 0 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
    font-weight: 200px;
    position: relative;
    background: rgba(7, 17, 27, 0.2);
    .gonggao_title {
      vertical-align: middle;
      display: inline-block;
      width: 22px;
      height: 12px;
      background: url("./img/bulletin@3x.png") no-repeat 0 0 / cover;
      margin: 0 4px;
    }
    .gonggao_text {
      vertical-align: middle;
    }
    .gonggao_jt {
      position: absolute;
      right: 12px;
      font-size: 12px;
    }
  }
  .background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(10px);
  }
  .detail {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    width: 100%;
    height: 100%;
    overflow: auto;
    /* opacity: 1; */
    background: rgba(7, 17, 27, 0.8);
    transition: all 0.5s;
    backdrop-filter: blur(10px);
    .clearfix:after {
      content: ".";
      display: block;
      height: 0;
      clear: both;
      visibility: hidden;
    }
    .detail-wrapper {
      min-height: 100%;
      width: 100%;
      .detail-main {
        padding-top: 64px;
        padding-bottom: 64px;
        h1 {
          font-size: 16px;
          font-weight: 700;
          color: #fff;
          line-height: 16px;
          text-align: center;
          margin-bottom: 16px;
        }
        .title {
          display: flex;
          align-items: center;
          width: 80%;
          margin: 30px auto 24px auto;
          .line {
            flex: 1;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
          }
          .text {
            font-size: 15px;
            color: #fff;
            font-weight: bold;
            padding: 0 12px;
          }
        }
        .supports {
          width: 70%;
          margin: 0 auto;
          .supports-item {
            display: flex;
            align-items: center;
            font-size: 16px;
            font-weight: 200px;
            line-height: 12px;
            color: #fff;
            margin-bottom: 12px;
          }
        }
        .conent {
          width: 70%;
          margin: 0 auto;
          line-height: 24px;
          font-size: 12px;
          color: #fff;
          font-weight: 200px;
        }
      }
    }
    .detail-close {
      position: relative;
      width: 32px;
      height: 32px;
      margin: -64px auto 0 auto;
      clear: both;
      font-size: 32px;
    }
  }
}
.jian {
  display: inline-block;
  width: 15px;
  height: 15px;
  background: url("./img/decrease_3@2x.png") no-repeat 0 0 / cover;
  margin-right: 6px;
}
.jian1 {
  display: inline-block;
  width: 15px;
  height: 15px;
  background: url("./img/discount_3@2x.png") no-repeat 0 0 / cover;
  margin-right: 6px;
}
.jian2 {
  display: inline-block;
  width: 15px;
  height: 15px;
  background: url("./img/guarantee_3@2x.png") no-repeat 0 0 / cover;
  margin-right: 6px;
}
.jian3 {
  display: inline-block;
  width: 15px;
  height: 15px;
  background: url("./img/invoice_3@2x.png") no-repeat 0 0 / cover;
  margin-right: 6px;
}
.jian4 {
  display: inline-block;
  width: 15px;
  height: 15px;
  background: url("./img/special_3@2x.png") no-repeat 0 0 / cover;
  margin-right: 6px;
}
.fade--leave-active {
  transition: all 1s;
}
.fade-leave {
  opacity: 1;
  background: rgba(7, 17, 27, 0.8);
}
.fade-leave-to {
  opacity: 0;
  background: rgba(7, 17, 27, 0);
}
</style>
